﻿using System;
using System.Collections.Generic;
using ActionLogic;
using Model;

namespace BehaviorModel
{
    /// <summary>
    /// Describes request buffer.
    /// </summary>
    public interface IRequestBuffer
    {
        /// <summary>
        /// Max capacity.
        /// </summary>
        int MaxCapacity { get; set; }

        /// <summary>
        /// Max request waiting time in queue.
        /// </summary>
        int MaxWaitingTime { get; set; }

        /// <summary>
        /// Request choosing discipline.
        /// </summary>
        ChoosingDiscipline Discipline { get; set; }

        /// <summary>
        /// Returns count of requests.
        /// </summary>
        int Count { get; }

        /// <summary>
        /// Invoked when added new request.
        /// </summary>
        event Action OnRequestAdded;

        /// <summary>
        /// Invoked when request was rejected (when BufferState = Full)
        /// </summary>
        event Action<Request> OnRequestRejected;

        /// <summary>
        /// Adds new request in buffer.
        /// </summary>
        /// <param name="newRequest">New request</param>
        void Add(Request newRequest);

        /// <summary>
        /// Returns last added request.
        /// </summary>
        /// <returns></returns>
        Request Get();

        /// <summary>
        /// Returns all requests from buffer.
        /// </summary>
        /// <returns></returns>
        IEnumerable<Request> GetAllRequest();

        /// <summary>
        /// Updates request waiting time by adding to each arg waitingTime.
        /// All requests who's waiting time is enough would be rejected.
        /// </summary>
        /// <param name="waitingTime">Adding waiting time</param>
        void UpdateWaitingQueue(double waitingTime);

        /// <summary>
        /// Defines whether empty buffer or not.
        /// </summary>
        /// <returns>True if empty, false in other cases</returns>
        bool IsEmtpy();

        /// <summary>
        /// Clean buffer.
        /// </summary>
        void Clear();
    }
}
